// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/equipment/api/AssetManageApi'

import DownloadClass from '@api/equipment/model/AssetReq'
import UploadClass from '@api/equipment/model/AssetImportByExcelReq'
import UpProgressClass from '@api/equipment/model/AssetExcelProgressQueryReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 下载 —————————————————————————————— //

  async download(downParam, TIP = '下载模板') {
    const DTO = CORE.grpcDTO(DownloadClass, downParam)
    await CORE.grpcDownload(TIP, CLIENT, 'downloadAssetImportModel', DTO, null, '设备导入模板.xlsx')
    return CORE.grpcOK(TIP)
  },

  // —————————————————————————————— 上传 —————————————————————————————— //

  async upload(upParam, TIP = '上传文件') {
    const DTO = CORE.grpcDTO(UploadClass, upParam)
    const resp = await CORE.grpc(TIP, CLIENT, 'importAssetByExcel', DTO)
    return resp.taskId
  },

  // —————————————————————————————— 上传进度 —————————————————————————————— //

  async upProgress(upProgress, TIP = '查询上传进度') {
    const DTO = CORE.grpcDTO(UpProgressClass, upProgress)
    const resp = await CORE.grpc(TIP, CLIENT, 'queryAssetExcelProgress', DTO)
    return resp
  },
}
